from builtins import str
import tushare as ts
import pandas as pd
from .data_source_adapter import DataSourceAdapter

class TushareAdapter(DataSourceAdapter):
    def __init__(self, token: str):
        self.pro = ts.pro_api(token)

    def get_daily_data(self, symbol: str, start_date: str, end_date: str) -> pd.DataFrame:
        df = self.pro.daily(ts_code=symbol, start_date=start_date, end_date=end_date)
        df = df.rename(columns={'trade_date': 'date', 'ts_code': 'symbol'})
        return df[['symbol', 'date', 'open', 'high', 'low', 'close', 'vol']]
